﻿<?PHP
  class Installer{
    public $step         = 1;
    public $allsteps     = 5;
    public $steps        = null;
    public $params       = null;
    private $systemcheck = true;
    public $isInstalled  = false;

    public function __construct(){
      $this->addWelcomePage();
      $this->addLicencePage();
      $this->addCheckPage();
      $this->addDbSettings();
      $this->addSettings();
      $this->addFinish();
      $this->allsteps = sizeof($this->steps);
    }
    
    private function addWelcomePage(){
      $step['headline'] = 'Willkommen';
      $step['content']  = '<p>
        Willkommen zur ContentLion Installation!</p>
      <p>
        Sie haben mit ContentLion eine gute Wahl getroffen.<br />
        ContentLion ist ein simples und stabiles CMS, <br />
        was Sie nicht im Stich l&auml;sst!
      </p><p>
        Wenn Sie doch Probleme bei der Installation haben, <br />
        kann Ihnen 
        <a href="http://wiki.contentlion.org/index.php?title=Installation">
          dieser Artikel
        </a>
        weiterhelfen.
      </p>';
      $this->steps[] = $step;
    }
    
    private function addLicencePage(){
      $step['headline'] = 'Lizenz';
      $step['content']  = '
ContentLion f&auml;llt unter den Lizenzvertrag <a href="http://creativecommons.org/licenses/GPL/2.0/">CC-GNU GPL</a> der Version 2.0 oder h�her.<br />
Es gibt grob Beschrieben folgende Einschr&auml;nkungen:
<ul>
  <li>In jeder Vervielf&auml;tigung des Programmes muss ContentLion genannt werden.</li>
  <li>Jede Vervielf&auml;tigung muss unter der gleichen Lizenz angeboten werden</li>
  <li>Bei Weitergabe muss der lesbare Quellcode mit&uuml;bergeben werden</li>
</ul><a href="http://creativecommons.org/licenses/GPL/2.0/">
<img alt="CC-GNU GPL" border="0" src="http://creativecommons.org/images/public/cc-GPL-a.png" /></a><br />
';
      $this->steps[] = $step;
    }
    
    private function addCheckPage(){
      $step['headline'] = 'Systemcheck';
      $step['content']  = "<p>Hier werden die Systemanforderungen von ContentLion gepr&uuml;ft.<br />
                           Wenn etwas rot markiert ist, wird ContentLion auf Ihrem System leider nicht funktionieren.</p>
                           <table>
                             <tr>
                               <td>PHP Version</td>
                               <td class='";
      if(substr(phpversion(),0,1) >= 5){
        $step['content'] .= "right'>Stimmt";
      }
      else{
        $step['content'] .= "wrong'>Stimmt nicht";
        $this->systemcheck = false;
      }
      $step['content'] .= "    </td>
                             </tr>
                             <tr> 
                                <td valign=\"top\">Schreibrechte</td>
                                <td class='";
      $rights = "";
      $rights .= $this->checkDir("system");
      $rights .= $this->checkDir("content");
      $rights .= $this->checkDir("content/articles");
      $rights .= $this->checkDir("content/articles/errors");
      $rights .= $this->checkDir("content/uploads");
      $rights .= $this->checkDir("installer");
      $rights .= $this->checkDir("install.php");
      if(strlen($rights) > 0){
        $this->systemcheck = false;
        $step['content'] .= "wrong'>Fehlende Schreibrechte auf:<br />".$rights."<br /><a href=\"install.php?restart=1\">Neuer Versuch</a>";
      }
      else{
        $step['content'] .= "right'>Stimmt";
      }
      $step['content'] .= "    </td>
                             </tr>
                             <tr> 
                                <td valign=\"top\">SQLite</td>
                                <td class='";
      if(!class_exists("SQLiteDatabase")){
        $this->systemcheck = false;
        $step['content'] .= "wrong'>nicht vorhanden<br /><a href=\"install.php?restart=1\">Neuer Versuch</a>";
      }
      else{
        $step['content'] .= "right'>vorhanden";
      }
      $step['content'] .= "     </td>
                              </tr>
								<tr> 
                                <td valign=\"top\">PDO</td>
                                <td class='";
      if(!class_exists("PDO")){
        $this->systemcheck = false;
        $step['content'] .= "wrong'>nicht vorhanden<br /><a href=\"install.php?restart=1\">Neuer Versuch</a>";
      }
      else{
        $step['content'] .= "right'>vorhanden";
      }
      $step['content'] .= "     </td>
                              </tr>
                            </table>";
	 
      $this->steps[] = $step;
	  
	  
    }
    
    public function getHeadline(){
      return $this->steps[$this->step-1]['headline'];
    }

    public function checkDir($dir){
      $res = "";
      if(!is_writable($dir)) {
        $res = $dir."<br />";
      } 
      return $res;
    }
    
    public function getContent(){
      $res =  $this->steps[$this->step-1]['content'];
      
      if($this->step == $this->allsteps){
          $this->runInstallation();
      }
      if(isset($this->params[$this->step-1]) && $this->params[$this->step-1]){
        foreach($this->params[$this->step-1] as $name=>$value){
          $res = str_replace("{".$name."}",$value,$res);
        }
      }
      return $res;
    }
    
    private function runInstallation(){
      $this->writeDBSettings();
      include('system/dbsettings.php');
      $connection = mysql_connect($dbhost,$dbuser,$dbpassword);
      mysql_select_db($db,$connection);
      $this->createTables();
      $this->insertRows();
      $this->isInstalled = true;
    }
    
    private function addDbSettings(){
      $step['headline'] = 'Datenbank Einstellungen';
      $step['content']  = '
<table>
  <tr>
    <td>Host:</td>
    <td><input name="host" value="{host}" /></td>
  </tr>
  <tr>
    <td>Datenbank:</td>
    <td><input name="database" value="{database}" /></td>
  </tr>
  <tr>
    <td>Benutzer:</td>
    <td><input name="user" value="{user}" /></td>
  </tr>
  <tr>
    <td>Passwort:</td>
    <td><input name="password" type="password" value="{password}" /></td>
  </tr>
  <tr>
    <td>Tabellen Pr&auml;fix:</td>
    <td><input name="praefix" value="{praefix}" /></td>
  </tr>
</table>';
      $this->params[3]['host']     = 'localhost';
      $this->params[3]['database'] = '';
      $this->params[3]['user']     = '';
      $this->params[3]['password'] = '';
      $this->params[3]['praefix']  = 'cl_';
      $this->steps[] = $step;
    }
    
    private function addFinish(){
      $step['headline'] = 'Fertigstellen';
      $step['content']  = 'ContentLion wurde erfolgreich installiert.<br />
      Sie werden nun zur Login-Seite weitergeleitet.
      Sollte die Weiterleitung nicht funktionieren, klicken Sie <a href="login.html">hier</a>.';
      $this->steps[] = $step;
    }
    
    public function showBackButton(){
      return $this->step > 1 and $this->step != $this->allsteps;
    }
    
    public function showNextButton(){
      return $this->step < $this->allsteps-1;
    }
    
    public function showFinishButton(){
      return $this->step == $this->allsteps-1;
    }
    
    private function addSettings(){
      $step['headline'] = 'Website Einstellungen';
      $step['content']  = '
<table>
  <tr>
    <td>Name der Website:</td>
    <td><input name="name" value="{name}" /></td>
  </tr>
  <tr>
    <td>Benutzername:</td>
    <td><input name="user" value="{user}" /></td>
  </tr>
  <tr>
    <td>Password:</td>
    <td><input name="password" type="password" value="{password}" /></td>
  </tr>
</table>
';
      $this->params[4]['name']     = '';
      $this->params[4]['user']     = '';
      $this->params[4]['password'] = '';
      $this->steps[] = $step;
    }
      
    public function validateCurrentStep(){
      return $this->step != 3 or $this->systemcheck;
    }
    
    private function writeDBSettings(){
      $handle = fopen ( "system/dbsettings.php", "w" );
      fwrite($handle,'
<?PHP
  $dbpraefix = "'.$this->params[3]['praefix'].'";
  $dbhost = "'.$this->params[3]['host'].'";
  $dbpassword = "'.$this->params[3]['password'].'";
  $dbuser = "'.$this->params[3]['user'].'";
  $db = "'.$this->params[3]['database'].'";
?>');
      fclose($handle );
    }
    
    private function createTables(){
      mysql_query("CREATE TABLE `".$this->params[3]['praefix']."activated_plugins` (
  `path` varchar(100) NOT NULL,
  PRIMARY KEY  (`path`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."custom_css` (
  `id` varchar(100) NOT NULL,
  `stylePath` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."dashboards` (
  `alias` varchar(255) NOT NULL,
  `col` int(1) NOT NULL,
  `row` int(2) NOT NULL,
  `path` varchar(255) NOT NULL,
  PRIMARY KEY  (`alias`,`col`,`row`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."events` (
  `event` varchar(50) NOT NULL,
  `file` varchar(50) NOT NULL,
  PRIMARY KEY  (`event`,`file`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."images` (
  `path` varchar(255) NOT NULL,
  `name` varchar(75) NOT NULL,
  `description` varchar(255) NOT NULL,
  PRIMARY KEY  (`path`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."menu` (
  `id` int(2) NOT NULL,
  `menuID` int(3) NOT NULL,
  `title` varchar(100) NOT NULL,
  `href` varchar(255) NOT NULL,
  `type` int(1) NOT NULL,
  PRIMARY KEY  (`id`,`menuID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."menu_names` (
  `id` int(4) NOT NULL auto_increment,
  `name` varchar(50) NOT NULL,
  `dir` varchar(50) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."meta_global` (
  `name` varchar(100) NOT NULL,
  `content` varchar(100) NOT NULL,
  PRIMARY KEY  (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."meta_local` (
  `name` varchar(100) NOT NULL,
  `page` int(11) NOT NULL,
  `content` varchar(100) NOT NULL,
  PRIMARY KEY  (`name`,`page`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."pages` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `alias` varchar(255) NOT NULL,
  `title` varchar(255) NOT NULL,
  `owner` int(11) NOT NULL DEFAULT '-1',
  `menu` int(11) NOT NULL DEFAULT '-1',
  `editor` varchar(50) NOT NULL DEFAULT 'WYSIWYG',
  `content` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1000;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."settings` (
  `role` int(11) NOT NULL default '3',
  `dir` varchar(100) NOT NULL,
  `area` varchar(20) NOT NULL,
  `areaType` varchar(20) NOT NULL,
  `property` varchar(100) NOT NULL,
  `value` varchar(255) NOT NULL,
  `activated` int(1) NOT NULL default '1',
  `description` varchar(75) NOT NULL,
  `type` varchar(50) NOT NULL,
  PRIMARY KEY  (`role`,`dir`,`area`,`areaType`,`property`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."skins` (
  `id` int(3) NOT NULL auto_increment,
  `name` varchar(30) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."user` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(50) NOT NULL,
  `password` varchar(50) NOT NULL,
  `role` int(11) NOT NULL,
  PRIMARY KEY  (`id`,`name`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."widgets` (
  `path` varchar(255) NOT NULL,
  `name` varchar(50) NOT NULL,
  `class` varchar(50) NOT NULL,
  `category` int(4) NOT NULL,
  PRIMARY KEY  (`path`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."roles` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(50) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."pagetypes` (
  `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
  `class` VARCHAR( 50 ) NOT NULL ,
  `name` VARCHAR( 50 ) NOT NULL ,
  PRIMARY KEY ( `id` ) ) TYPE = MYISAM ;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."role_rights` (
  `role` int(11) NOT NULL,
  `page` int(11) NOT NULL,
  PRIMARY KEY  (`role`,`page`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE `".$this->params[3]['praefix']."packages` (
  `name` varchar(50) NOT NULL,
  `version` int(11) NOT NULL,
  PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."tasks` (
  `script` varchar(50) NOT NULL,
  `interval` int(11) NOT NULL,
  `lastExecution` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`script`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."actionlists` (
  `category` varchar(50) NOT NULL,
  `id` int(11) NOT NULL,
  `icon` varchar(20) NOT NULL,
  `destination` varchar(255) NOT NULL,
  `label` varchar(50) NOT NULL,
  PRIMARY KEY (`category`,`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."widget_categories` (
  `id` int(4) NOT NULL,
  `name` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."controls` (
  `name` varchar(50) NOT NULL,
  `label` varchar(50) NOT NULL,
  PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."datafields` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `dataType` int(11) NOT NULL,
  `displayName` varchar(100) NOT NULL,
  `dataName` varchar(100) NOT NULL,
  `validator` int(4) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=93 ;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."datarights` (
  `datatype` int(11) NOT NULL,
  `role` int(11) NOT NULL,
  PRIMARY KEY (`datatype`,`role`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."datatypes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `displayName` varchar(100) NOT NULL,
  `dataName` varchar(100) NOT NULL,
  `description` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=28 ;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."data_validator` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `regex` varchar(255) NOT NULL,
  `message` varchar(255) NOT NULL,
  `htmlCode` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."forms` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL,
  `dir` varchar(255) NOT NULL,
  `destinationType` int(1) NOT NULL,
  `buttonText` varchar(50) NOT NULL,
  `datatype` int(11) NOT NULL,
  `captcha` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."form_fields` (
  `form` int(11) NOT NULL,
  `dataName` varchar(50) NOT NULL,
  `sortIndex` int(3) NOT NULL,
  `insert` bit(1) NOT NULL,
  `show` bit(1) NOT NULL,
  `mandatory` bit(1) NOT NULL,
  `label` varchar(100) NOT NULL,
  `preallocate` varchar(255) NOT NULL,
  `edit` varchar(255) NOT NULL,
  PRIMARY KEY (`form`,`dataName`),
  UNIQUE KEY `sortIndex` (`sortIndex`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."language_tokens` (
  `token` varchar(50) NOT NULL,
  PRIMARY KEY (`token`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
mysql_query("CREATE TABLE IF NOT EXISTS `".$this->params[3]['praefix']."languages` (
  `token` varchar(2) NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`token`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;");
}



    private function insertRows(){
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu_names` VALUES (1, '{LANG:MAIN_MENU} (Backend)','/admin');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu_names` VALUES (2, '{LANG:MAIN_MENU}','');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu_names` VALUES (3, '{LANG:FILE}','/admin');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu_names` VALUES (4, '{LANG:USER}','/admin');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu_names` VALUES (5, '{LANG:SETTINGS}','/admin');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu_names` VALUES (6, '{LANG:EXTRAS}','/admin');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu_names` VALUES (7, '?','/admin');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu_names` VALUES (8, '{LANG:FILE} - {LANG:NEW}','/admin');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (1, 1, '{LANG:FILE}', '3',3);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (2, 1, '{LANG:USER}', '4',3);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (3, 1, '{LANG:EXTRAS}', '5',3);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (4, 1, '?', '6',3);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (1, 2, '{LANG:HOMEPAGE}', '1', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (2, 2, '{LANG:LOGIN}', '2', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (1, 3, 'Dashboard', '5', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (2, 3, '{LANG:NEW}', '8', 3);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (3, 3, '{LANG:SETTINGS}', '6',0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (4, 3, '{LANG:CLOSE}', 'javascript:window.close()', 1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (1, 8, '{LANG:FOLDER}', '10', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (2, 8, '{LANG:PAGE}', '9', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (3, 8, '{LANG:MENU}', 'javascript:showIFrameDialog(\'Neues Menü\',300,200,\'{VAR:HOST}admin/newmenu.html?blank=true\',true);', 1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (4, 8, '{LANG:UPLOAD}', '16', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (1, 4, '{LANG:MANAGE}', '8', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (2, 4, '{LANG:ROLES}', '18', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (1, 5, '{LANG:PLUGINS}', '4', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (1, 6, '{LANG:HELP}', 'http://wiki.contentlion.org', 1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (2, 6, 'Issue Tracker', 'http://code.google.com/p/contentlion/issues/list', 1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (3, 6, 'Blog', 'http://blog.stevieswebsite.de', 1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (4, 6, '{LANG:ABOUT}', '20', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (2, 5, 'Datenzentrale', '23', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (5, 8, 'Formular', 'javascript:showIFrameDialog(\'Neues Formular\',300,200,\'{VAR:HOST}admin/newform.html?blank=true\',true);', 1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."menu` VALUES (3, 5, 'Übersetzungen', '25', 0);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."user` VALUES (1, '".$this->params[4]['user']."', '".md5($this->params[4]['password'])."',2);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','global', 'global', 'title', '".$this->params[4]['name']."', 1, '{LANG:TITLE}','textbox');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','global', 'global', 'selectedskin', '1', 1, '{LANG:CURRENT_SKIN}','skinselector');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','global', 'global', 'selectedmobileskin', '2', 1, '{LANG:MOBILE_SKIN}','mobileskinselector');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','default', 'skins', 'skinbgcolor', 'dedede', 1, '{LANG:BACKGROUNDCOLOR}','colorpicker');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','default', 'skins', 'skinforecolor', '525252', 1, '{LANG:FONTCOLOR}','colorpicker');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','default', 'skins', 'skinhighlight1', 'ff0000', 1, '{LANG:HIGHLIGHT_COLOR} 1','colorpicker');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','default', 'skins', 'skinhighlight2', 'b3fa00', 1, '{LANG:HIGHLIGHT_COLOR} 2','colorpicker');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','global', 'global', 'host', '".$this->getCurrentFolderUrl()."', 1, 'Host','textbox');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','global', 'global', 'mainmenu', '2', 0, '{LANG:MAIN_MENU}', 'menueselector');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','global', 'global', 'accessdenied', '3', 1, '{LANG:ACCESS_DENIED_PAGE}', 'pageselector');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','global', 'global', 'iconset', 'famfamfam', 1, 'Iconset', 'iconsetselector');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (2,'global/admin','global', 'global', 'mainmenu', '1', 1, '{LANG:MAIN_MENU}', 'menueselector');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','global', 'global', 'language', 'de', 1, '{LANG:LANGUAGE}', 'languageselector');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (3,'global','global', 'global', 'root', '".$this->getServerRootPath()."', 1, 'Root-Path', 'textbox');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."settings` VALUES (2,'global/admin','global', 'global', 'selectedskin', '3', 1, '{LANG:CURRENT_SKIN}','skinselector');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."skins` VALUES (1, 'default');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."skins` VALUES (2, 'mobile');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."skins` VALUES (3, 'backenddefault');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."skins` VALUES (4, 'simple');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."roles` VALUES (1, '{LANG:GUEST}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."roles` VALUES (2, 'Administator');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."roles` VALUES (3, '{LANG:ALL}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."pagetypes` VALUES (1, 'wysiwyg', '{LANG:TEXTPAGE}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."pagetypes` VALUES (2, 'login', '{LANG:LOGIN}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."pagetypes` VALUES (3, 'dashboard', 'Dashboard');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."pagetypes` VALUES (4, 'listpage', 'Liste');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."pages` (`id`, `alias`, `title`, `owner`, `menu`, `editor`, `content`) VALUES
                     (1, 'home', 'Startseite', -1, 0, 'wysiwyg', '<h2>Herzlichen Gl&uuml;ckwunsch!</h2>\r\n<p>Sie haben die Startseite Ihres neuen Webprojekts entdeckt.</p>\r\n<p>Das ContentLion Team hei&szlig;t Sie herzlich willkommen. Sollten Sie Fragen oder Probleme mit ContentLion haben, k&ouml;nnen Sie das Wiki zur Hilfe nehmen oder sich im Forum melden.</p>\r\n<p>Wichtige Links:</p>\r\n<ul>\r\n<li><a href=\"http://wiki.contentlion.org\">Wiki</a></li>\r\n<li><a href=\"http://forum.stevieswebsite.de\">Forum</a></li>\r\n<li><a href=\"http://code.google.com/p/contentlion/\">GoogleCode Seite (inkl. Issue-Tracker)</a></li>\r\n<li><a href=\"http://blog.stevieswebsite.de/eigenes-cms-erstellen/\">Artikelliste</a></li>\r\n</ul>\r\n<p><span style=\"color:red\">Bitte denken Sie daran:</span></p>\r\n<p>Diese Version von ContentLion befindet sich noch in der Entwicklung.</p>\r\n<p>Einige Funktionen sind noch nicht verf&uuml;gbar, aber wir arbeiten dran</p>'),
                     (2, 'login', '{LANG:LOGIN}', -1, 0, 'login', ''),
                     (3, 'access-denied', '{LANG:ACCESS_DENIED}', -1, 0, 'wysiwyg', '<h1>Zugriff Verweigert!</h1>\r\n<p>Um diese Seite anzusehen hast Du zu wenig Rechte!</p>'),
                     (4, 'admin/plugins', '{LANG:PLUGINS}', 5, 0, 'pluginpage', ''),
                     (5, 'admin/home', 'Dashboard', -1, 0, 'dashboard', ''),
                     (6, 'admin/settings', '{LANG:SETTINGS}', 5, 0, 'settingspage', ''),
                     (7, 'admin/logout', '{LANG:LOGOUT}', 5, 0, 'logout', ''),
                     (8, 'admin/user', '{LANG:USER}', 5, 0, 'userlist', ''),
                     (9, 'admin/newpage', '{LANG:NEW_PAGE}', 5, 0, 'pagecreatorpage', ''),
                     (10, 'admin/newfolder', '{LANG:NEW_FOLDER}', 5, 0, 'newfolderpage', ''),
                     (11, 'admin/pageedit', '{LANG:EDIT_PAGE}', 5, 0, 'pageeditpage', ''),
                     (12, 'admin/pagedelete', '{LANG:DELETE_PAGE}', 5, 0, 'pagedeletepage', ''),
                     (13, 'admin/newmenu', '{LANG:NEW_MENU}', 5, 0, 'menucreatorpage', ''),
                     (14, 'admin/editmenu', '{LANG:EDIT_MENU}', 5, 0, 'menueditor', ''),
                     (15, 'admin/deletemenu', '{LANG:DELETE_MENU}', 5, 0, 'menudeletepage', ''),
                     (16, 'admin/upload', '{LANG:UPLOAD}', 5, 0, 'uploader', ''),
                     (17, 'admin/media/addimage', '{LANG:ADD_IMAGE}', 5, 0, 'addimagepage', ''),
                     (18, 'admin/roles', '{LANG:ROLES}', 5, 0, 'rolelist', ''),
                     (19, 'admin/pluginsettings', 'Plugineinstellungen', 6, 0, 'pluginsettingspage', ''),
                     (20, 'admin/about', 'Über ContentLion', 5, 0, 'wysiwyg', '<h2>&Uuml;ber Contentlion</h2><p><img style=\"float: right;\" title=\"ContentLion Logo\" src=\"http://images.contentlion.org/logo.png\" alt=\"ContentLion Logo\" width=\"377\" height=\"295\" /></p><p>Version: 1.0.0</p><p>Website: <a href=\"http://contentlion.org\">http://contentlion.org</a></p><h3>Mitwirkende</h3><ul><li>Stefan Wienstr&ouml;er</li><li>Daniel Busch</li><li>die Leser von <a href=\"http://stevieswebsite.de\">SteviesWebsite</a></li></ul><h3>Third parties</h3><p>ContentLion beinhaltet folgende Fremdkomponenten:</p><ul><li><a href=\"http://jquery.com/\">jQuery</a></li><li><a href=\"http://tinymce.moxiecode.com/\">TinyMCE</a></li></ul><p>ContentLion wird gehostet auf <a href=\"http://code.google.com/intl/de-DE/projecthosting/\">Google Project Hosting</a>.</p>'),
                     (21, 'admin/newform', 'Neues Formular', 5, 0, 'formcreatorpage', ''),
                     (22, 'admin/formedit', 'Formular Bearbeiten', 5, 0, 'formeditor', ''),
                     (23, 'admin/data', 'Datenzentrale', 5, 0, 'datacenter', ''),
                     (24, 'admin/tinymce/forms', 'Formulare', -1, 0, 'listpage', 'O:10:\"CustomList\":5:{s:8:\"template\";s:8:\"formlist\";s:11:\"showButtons\";b:0;s:11:\"paddingLeft\";i:0;s:4:\"name\";s:0:\"\";s:10:\"fillSelect\";s:31:\"SELECT * FROM {''dbprefix''}forms\";}'),
                     (25, 'admin/translations', 'Übersetzungen', 5, 0, 'translationpage', ''),
                     (26, 'admin/edittranslation', 'Übersetzung Bearbeiten', 25, 0, 'translationeditor', ''),
                     (27, 'admin/language-token-editor', 'Übersetzungstoken bearbeiten', 26, 0, 'TranslationTokenEditor', '');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."dashboards` VALUES ('admin/home', 2, 1, 'settingswidget/settingswidget.php');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."dashboards` VALUES ('admin/home', 1, 1, 'pagelistwidget/pagelistwidget.php');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."dashboards` VALUES ('admin/home', 3, 1, 'filelistwidget/filelistwidget.php');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."dashboards` VALUES ('admin/home', 3, 2, 'menulistwidget/menulistwidget.php');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."dashboards` VALUES ('admin/home', 1, 2, 'updater/widget.php');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."dashboards` VALUES ('admin/home', 3, 3, 'formlistwidget/formlistwidget.php');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."widgets` VALUES ('contentliontips/contentliontipswidget.php', 'Contentlion Tipps', 'ContentLionTipsWidget',2);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."widgets` VALUES ('pagelistwidget/pagelistwidget.php', 'PageList', 'PageListWidget',1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."widgets` VALUES ('filelistwidget/filelistwidget.php', 'FileList', 'FileListWidget',1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."widgets` VALUES ('menulistwidget/menulistwidget.php', 'MenuList', 'MenuListWidget',1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."widgets` VALUES ('updater/widget.php', 'Updater', 'Updater',1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."widgets` VALUES ('settingswidget/settingswidget.php', 'SettingsWidget', 'SettingsWidget',1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."widgets` VALUES ('formlistwidget/formlistwidget.php', 'FormListWidget', 'FormListWidget',1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (1,1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (1,2);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (1,3);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,2);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,3);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (3,1);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (3,2);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (3,3);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,4);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,5);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,6);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,7);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,8);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,9);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,10);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,11);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,12);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,13);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,14);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,15);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,16);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,17);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,18);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,19);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,20);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,21);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,22);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,23);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,24);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,25);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,26);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."role_rights` VALUES (2,27);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."activated_plugins` VALUES ('lookaround');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."activated_plugins` VALUES ('contentliontips');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."activated_plugins` VALUES ('pagelistwidget');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."activated_plugins` VALUES ('filelistwidget');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."activated_plugins` VALUES ('menulistwidget');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."activated_plugins` VALUES ('settingstwidget');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."activated_plugins` VALUES ('updater');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."activated_plugins` VALUES ('formlistwidget');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('contentlion-core', 32)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('plugin_lookaround', 1)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('plugin_updater', 5)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('plugin_filelistwidget', 6)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('plugin_menulistwidget', 3)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('plugin_pagelistwidget', 3)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('plugin_settingswidget', 2)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('skin_default', 3)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('skin_simple', 1)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('skin_mobile', 1)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('skin_backaenddefault', 2)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('plugin_jquery', 1)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('plugin_formlistwidget', 1)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."packages` (`name`, `version`) VALUES ('plugin_contentliontips', 2)");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."tasks` (`script` ,`interval` ,`lastExecution` ) VALUES ('system/tasks/clearcache.php', '720', NULL );");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."actionlists` (`category`, `id`, `icon`, `destination`, `label`) VALUES ('userlist', 1, 'cross', '{VAR:HOST}admin/user.html?delete={VAR:ID}', '{LANG:DELETE}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."actionlists` (`category`, `id`, `icon`, `destination`, `label`) VALUES ('plugin_filelistwidget', 1, 'pencil', 'javascript:showRenameFileDialog(\'{VAR:FILE}\')', '{LANG:RENAME}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."actionlists` (`category`, `id`, `icon`, `destination`, `label`) VALUES ('plugin_filelistwidget', 2, 'cross', '{VAR:HOST}admin/home.html?dir={VAR:DIR}&deletefile={VAR:FILE}', '{LANG:DELETE}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."actionlists` (`category`, `id`, `icon`, `destination`, `label`) VALUES ('menuedit', 1, 'bullet_arrow_up', '{VAR:HOST}admin/editmenu.html?menu={VAR:MENU}&moveup={VAR:ID}', '{LANG:MOVEUP}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."actionlists` (`category`, `id`, `icon`, `destination`, `label`) VALUES ('menuedit', 2, 'bullet_arrow_down', '{VAR:HOST}admin/editmenu.html?menu={VAR:MENU}&movedown={VAR:ID}', '{LANG:MOVEDOWN}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."actionlists` (`category`, `id`, `icon`, `destination`, `label`) VALUES ('menuedit', 3, 'cross', '{VAR:HOST}admin/editmenu.html?menu={VAR:MENU}&delete={VAR:ID}', '{LANG:DELETE}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."actionlists` (`category`, `id`, `icon`, `destination`, `label`) VALUES ('rolelist', 1, 'cross', '{VAR:HOST}admin/roles.html?delete={VAR:ID}', '{LANG:DELETE}');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."actionlists` (`category`, `id`, `icon`, `destination`, `label`) VALUES ('translations', 1, 'pencil', '{VAR:HOST}admin/edittranslation.html?language={VAR:TOKEN}', '{LANG:EDIT}')");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."actionlists` (`category`, `id`, `icon`, `destination`, `label`) VALUES ('translation_tokens', 1, 'pencil', 'javascript:showIFrameDialog(\'{VAR:TOKEN}\',300,200,\'{VAR:HOST}admin/language-token-editor.html?token={VAR:TOKEN}&language={VAR:LANGUAGE}&blank=true\',true);', 'Bearbeiten')");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."actionlistscontrols` (`name`, `label`) VALUES
('combobox', 'Combobox'),
('colorpicker', 'Farbpicker'),
('textbox', 'TextBox'),
('iconsetselector', 'IconSet Selector'),
('languageselector', 'Sprachauswahl'),
('menueselector', 'Menüauswahl'),
('mobileskinselector', 'mobile Skin-Auswahl'),
('roleselector', 'Rollenauswahl'),
('skinselector', 'Skin-Auswahl');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."datafields` (`id`, `dataType`, `displayName`, `dataName`, `validator`) VALUES
(1, 1, 'Alias', 'alias', 3),
(2, 1, 'Titel', 'title', 3),
(3, 2, 'Kategorie', 'category', 1),
(4, 2, 'Eintrag', 'id', 2),
(5, 2, 'Icon', 'icon', 11),
(6, 2, 'Ziel', 'destination', 3),
(7, 2, 'Beschriftung', 'label', 1),
(8, 3, 'Path', 'path', 8),
(9, 4, 'Name', 'name', 1),
(10, 4, 'Beschriftung', 'label', 1),
(11, 5, 'id', 'Seite', 8),
(12, 5, 'Stylesheet-Adresse', 'stylePath', 8),
(13, 6, 'Dashboard', 'alias', 3),
(14, 6, 'Spalte', 'col', 4),
(15, 6, 'Zeile', 'row', 7),
(16, 6, 'Path', 'path', 3),
(17, 7, 'Id', 'id', 2),
(18, 7, 'Datentyp', 'dataType', 2),
(19, 7, 'Name', 'displayName', 8),
(20, 7, 'Datenname', 'dataName', 8),
(21, 8, 'Datentyp', 'dataType', 2),
(22, 8, 'Rolle', 'role', 2),
(24, 9, 'Event-Name', 'event', 1),
(25, 9, 'Datei', 'file', 1),
(26, 7, 'Validator', 'validator', 9),
(27, 10, 'ID', 'id', 2),
(28, 10, 'Name', 'name', 1),
(29, 10, 'Rolle', 'role', 2),
(30, 11, 'Id', 'id', 2),
(31, 11, 'Name', 'name', 1),
(32, 11, 'Regulärer Ausdruck', 'regex', 3),
(33, 11, 'Meldung', 'message', 3),
(34, 12, 'Id', 'id', 2),
(35, 12, 'Name', 'name', 1),
(36, 12, 'Verzeichnis', 'dir', 3),
(37, 12, 'Zieltyp', 'destinationtype', 4),
(38, 12, 'Absenden-Text', 'buttonText', 1),
(39, 13, 'Formular-Id', 'form', 2),
(40, 13, 'Datenname', 'name', 1),
(41, 13, 'Reihenfolge', 'sortIndex', 5),
(94, 13, 'Einfügen', 'insert', 12),
(43, 13, 'Beschriftung', 'label', 1),
(44, 14, 'Bild-Url', 'path', 3),
(45, 14, 'Name', 'name', 6),
(46, 14, 'Beschreibung', 'description', 3),
(47, 15, 'Id', 'id', 7),
(48, 15, 'Menü-Id', 'menuID', 5),
(49, 15, 'Beschriftung', 'title', 8),
(50, 15, 'Ziel', 'href', 4),
(51, 16, 'Id', 'id', 9),
(52, 16, 'Name', 'name', 1),
(53, 16, 'Verzeichnis', 'dir', 1),
(54, 17, 'Name', 'name', 8),
(55, 17, 'Inhalt', 'content', 8),
(56, 18, 'Name', 'name', 8),
(57, 18, 'Seite', 'page', 2),
(58, 18, 'Inhalt', 'content', 8),
(59, 19, 'Name', 'name', 1),
(60, 19, 'Version', 'version', 1),
(61, 20, 'id', 'Id', 2),
(62, 20, 'Name', 'name', 1),
(63, 1, 'Id', 'id', 2),
(64, 1, 'Besitzer', 'owner', 2),
(65, 1, 'Menü', 'menu', 2),
(66, 1, 'Seitentyp', 'editor', 1),
(67, 1, 'Inhalt', 'content', 10),
(68, 21, 'Id', 'id', 2),
(69, 21, 'PHP-Klasse', 'class', 1),
(70, 21, 'name', 'Name', 1),
(71, 22, 'Rolle', 'role', 2),
(72, 22, 'Seite', 'page', 2),
(73, 23, 'Rolle', 'role', 2),
(74, 23, 'Verzeichnis', 'dir', 8),
(75, 23, 'Bereich', 'area', 11),
(76, 23, 'Bereich-Typ', 'areaType', 11),
(77, 23, 'Eigenschaft', 'property', 8),
(78, 23, 'Wert', 'value', 3),
(79, 23, 'Aktiviert', 'activated', 12),
(80, 23, 'Beschreibung', 'description', 6),
(81, 23, 'Typ', 'type', 1),
(82, 24, 'Id', 'id', 5),
(83, 24, 'Name', 'name', 1),
(84, 25, 'auszufürende Datei', 'script', 1),
(85, 25, 'Interval (in Minuten)', 'interval', 2),
(86, 25, 'Letzte AusfÃ¼hrung', 'lastExecution', 13),
(87, 26, 'Path (system/plugins/...)', 'path', 3),
(88, 26, 'Name', 'name', 1),
(89, 26, 'Klasse', 'class', 1),
(90, 26, 'Kategorie', 'category', 9),
(91, 27, 'Id', 'id', 9),
(92, 27, 'name', 'Name', 8),
(93, 12, 'Datentyp', 'datatype', 2),
(95, 13, 'Pflicht', 'mandatory', 12),
(96, 13, 'Einblenden', 'show', 12),
(97, 13, 'Vorbelegung (SQL)', 'preallocate', 3),
(98, 13, 'Verarbeitung (SQL)', 'edit', 3),
(99, 28, 'Token', 'token', 14),
(100, 28, 'Name', 'name', 3),
(101, 11, 'Html-Code', 'htmlCode', 3);");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."datatypes` (`id`, `displayName`, `dataName`, `description`) VALUES
(2, 'Aktionslisten', 'actionlists', 'Gibt an, welche Aktionen an einer gewissen Stelle CMS ausgeführt werden können'),
(1, 'Seiten', 'pages', 'Das sind die einzelnen Seiten des CMS.'),
(3, 'Aktivierte Plugins', 'activated_plugins', 'Hier sind die verzeichnisse der aktivieren Plugins.'),
(4, 'Steuerelemente', 'controls', 'Hier sind alle dynamischen Steuerelemente die genutzt werden können.'),
(5, 'Benutzerdefiniertes CSS', 'custom_css', 'Hier können pro Seite benutzerdefinierte Stylesheets angegeben werden.'),
(6, 'Dashboard Einträge', 'dashboards', 'Die einzelnen Widgets auf dem Dashboards.'),
(7, 'Datenfelder', 'datafields', 'Die einzelnen Datenfelder.'),
(8, 'Datenrechte', 'datarights', 'Die Zugriffsrechte auf die Daten.'),
(9, 'Ereignisse', 'events', 'Speichert Scripts, die bei bestimmten Ereignissen in ContentLion ausgeführt werden sollen.'),
(10, 'Benutzer', 'user', 'Die Benutzer deines Systems.'),
(11, 'Datenvalidierung', 'data_validator', 'Gibt die Regeln an, nach denen die einzelnen Datenfelder validiert werden sollen. So kann man zum Beispiel sagen, dass in einem Feld nur Zahlen dürfen.'),
(12, 'Formulare', 'forms', 'Die erstellten Formulare.'),
(13, 'Formularfelder', 'form_fields', 'Das sind die einzelnen Steuerelemente, die zu einem Formular angezeigt werden.'),
(14, 'Bilder', 'images', 'Die in die Mediathek eingefügten Bilder.'),
(15, 'Menüeinträge', 'menu', 'Die Einträge deiner Menüs.'),
(16, 'Menüs', 'menu_names', 'Die Namen der Menüs.'),
(17, 'Metadaten (Global)', 'meta_global', 'Html-Meta-Tags, die auf allen Seiten eingefügt werden sollen'),
(18, 'Metadaten (Lokal)', 'meta_local', 'Html-Meta-Tags auf einzelne Seiten bezogen.'),
(19, 'Pakete', 'packages', 'Hier stehen die Namen und Versionen der installierten Pakete von ContentLion. Diese können Skin, Plugins oder auch der ContentLion-Core sein.'),
(20, 'Rollen', 'roles', 'Die Rollen des CMS.'),
(21, 'Seitentypen', 'pagetypes', 'Die Seitentypen (WYSIWYG, Dashboard,...)'),
(22, 'Rollenrechte', 'role_rights', 'Regelt die Zugriffsrechte der Rollen auf bestimmte Seiten.'),
(23, 'Einstellungen', 'settings', 'Die Einstellungen des CMS.'),
(24, 'Skins', 'skin', 'Die einzelnen Skins des CMS (liegen im Ordner system/skins).'),
(25, 'Aufgaben', 'tasks', 'Speichert automatisch auszuführende Aufgaben für ContentLion.'),
(26, 'Widgets', 'widgets', 'Die einzelnen Widgets (z.B. fürs Dashboard).'),
(27, 'Widget Kategorien', 'widget_categories', 'Kategorien der Widgets.'),
(28, 'Sprachen', 'languages', 'Die verfügbaren Sprachen.');");
      mysql_query("INSERT INTO `".$this->params[3]['praefix']."data_validator` (`id`, `name`, `regex`, `message`) VALUES
(1, 'Text (50 Zeichen)', '^.{0,50}$', 'Der Wert {VAR:FIELD} darf max. 50 Zeichen lang sein.'),
(2, 'Ganzzahl', '-?[0-9]{1,11}', 'Bitte gebe eine ganze Zahl ein.'),
(3, 'Text (255 Zeichen)', '^.{0,255}$', 'Hier dürfen maximal 255 Zeichen angegeben werden!'),
(4, 'Ganzzahl (0-9)', '[0-9]', 'Bitte gebe eine Zahl von  null - neun an!'),
(5, 'Ganzzahl (0-999)', '[0-9]{1,3}', 'Bitte gebe eine Zahl von 0-999 ein.'),
(6, 'Text (75 Zeichen)', '^.{0,75}$', 'Bitte gebe max. 75 Zeichen ein.'),
(7, 'Ganzzahl (0-99)', '[0-9]?[0-9]', 'Bitte gebe eine Zahl von 0-99 ein.'),
(8, 'Text (100 Zeichen)', '^.{0,100}$', 'Bitte gebe max. 100 Zeichen ein.'),
(9, 'Ganzzahl (0-9999)', '[0-9]{1,4}', 'Bitte gebe eine Zahl bis 9999 ein.'),
(10, 'Text', '^.*$', ''),
(11, 'Text (20 Zeichen)', '^.{0,20}$', 'Bitte gebe max. 20 Zeichen ein.'),
(12, 'Ja oder Nein', '[0-1]', 'Bitte gebe Ja (1) oder Nein (0) an.'),
(13, 'Datum mit Uhrzeit', '^[0-9]{0,4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]$', 'Das Feld muss ein Datum sein.');");
mysql_query("INSERT INTO `".$this->params[3]['praefix']."controls` (`name`, `label`) VALUES
('combobox', 'Combobox'),
('colorpicker', 'Farbpicker'),
('textbox', 'TextBox'),
('iconsetselector', 'IconSet Selector'),
('languageselector', 'Sprachauswahl'),
('menueselector', 'Menüauswahl'),
('mobileskinselector', 'mobile Skin-Auswahl'),
('roleselector', 'Rollenauswahl'),
('skinselector', 'Skin-Auswahl');");
mysql_query("INSERT INTO `".$this->params[3]['praefix']."language_tokens` (`token`) VALUES
('ABOUT'),
('ACCESS_DENIED'),
('ACCESS_DENIED_PAGE'),
('ACTION'),
('ACTIONS'),
('ADD'),
('ADD_ENTRIES'),
('ADD_IMAGE'),
('ADD_IMAGE_TO_MEDIALIBARY'),
('ALIAS'),
('ALL'),
('AUTHOR'),
('BACKGROUNDCOLOR'),
('CANCEL'),
('CHANGE'),
('CHANGE_SETTINGS'),
('CLOSE'),
('CONTENT'),
('CREATE'),
('CREATE_PAGE'),
('CURRENT_SKIN'),
('DELETE'),
('DELETE_MENU'),
('DELETE_MENU_ASK'),
('DELETE_PAGE'),
('DESCRIPTION'),
('DIR'),
('DISABLE'),
('EDIT'),
('EDIT_MENU'),
('EDIT_PAGE'),
('ENABLE'),
('ENTER_LINK_TARGET'),
('ENTER_LINK_TITLE'),
('ENTRY_ADD'),
('ENTRY_ADDED'),
('ENTRY_NOT_ADDED'),
('EXTRAS'),
('FILE'),
('FILENAME'),
('FILES'),
('FILE_NOT_UPLOADED'),
('FILE_UPLOADED'),
('FOLDER'),
('FONTCOLOR'),
('FORM'),
('FORM_CREATED'),
('GLOBAL'),
('GUEST'),
('HELP'),
('HIGHLIGHT_COLOR'),
('HOMEPAGE'),
('ID'),
('IMAGE_ADDED'),
('IMAGE_NOT_ADDED'),
('INSERT'),
('LANGUAGE'),
('LOGIN'),
('LOGIN_FAILED'),
('LOGOUT'),
('MAIN_MENU'),
('MANAGE'),
('MENU'),
('MENUS'),
('MENU_CREATED'),
('MENU_DELETED'),
('MENU_NOT_CREATED'),
('MENU_NOT_DELETED'),
('META_DATA'),
('MOBILE_SKIN'),
('MOVEDOWN'),
('MOVEUP'),
('NAME'),
('NEW'),
('NEW_FOLDER'),
('NEW_MENU'),
('NEW_PAGE'),
('NOOWNER'),
('NOT_UPDATED'),
('NO_FILES'),
('NO_MENU'),
('OWNER'),
('PAGE'),
('PAGES'),
('PAGE_CREATED'),
('PAGE_EXTERNAL'),
('PAGE_INTERNAL'),
('PAGE_MENU'),
('PAGE_NOT_CREATED'),
('PASTE'),
('PATH'),
('PLUGINS'),
('PREVIEW'),
('RENAME'),
('RENAME_FILE'),
('RIGHTS'),
('ROLE'),
('ROLES'),
('SAVE'),
('SETTINGS'),
('SKINS'),
('TEXT'),
('TEXTPAGE'),
('TITLE'),
('TYPE'),
('UPDATED'),
('UPLOAD'),
('UPlOAD_FAILED_IMAGE_SIZE'),
('UPlOAD_FAILED_NONE'),
('UPlOAD_FAILED_PARTIALLY'),
('UPlOAD_FAILED_SIZE'),
('UPLOAD_FILE'),
('USER'),
('VERSION'),
('WAS_DELETED');");
mysql_query("INSERT INTO `".$this->params[3]['praefix']."languages` (`token`, `name`) VALUES
('de', 'Deutsch'),
('en', 'English');");
    }

    function isHttps(){
      return isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on';
    }

    function getCurrentFolderUrl(){
      if($this->isHttps()){
        $res = "https://";
      }
      else{
        $res = "http://";
      }
      $res .= $_SERVER['HTTP_HOST'];
      $parts = explode("/",$_SERVER['REQUEST_URI']);
      for($i = 0;$i < count($parts) -1;$i++){
        $res .= $parts[$i]."/";
      }
      return $res;
    }

    function getServerRootPath(){
      $res = "";
      $parts = explode("/",$_SERVER['SCRIPT_FILENAME']);
      for($i = 0;$i < count($parts) -1;$i++){
        $res .= $parts[$i]."/";
      }
      return $res;
    }
    
    public function renameIndex(){
      unlink('index.php');
      rename("content/index.txt","index.php");
    }

    public function destroy(){
      unlink('installer/installer.php');
      unlink('installer/logo.jpg');
      rmdir('installer');
      unlink('install.php');
      $_SESSION['installer'] = null;
      unset($this);
    }

  }
?>